package cn.tsoft.taobao.ui;

import cn.tsoft.taobao.logic.ITaoBaoActivity;
import cn.tsoft.taobao.util.AuthorInfo;


import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.telephony.TelephonyManager;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.widget.ImageView;

/**
 *  用户授权的第一步 获取用户的登录的URL地址和session索取凭证
 *  同时这个activity也是登录logo页面的展示
 * @author wanggj
 *
 */
public class AuthorActivity  extends Activity{

	protected void onCreate(Bundle savedInstanceState) {
	    	    super.onCreate(savedInstanceState);
	    	    //取消标题
	    		this.requestWindowFeature(Window.FEATURE_NO_TITLE);
	    		//取消状态栏
	    		this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
	    				                  WindowManager.LayoutParams.FLAG_FULLSCREEN);
	    		setContentView(R.layout.log);
	    		//让logo出现几秒钟中的停顿，在这期间我们可以验证服务，获取淘宝需要的凭证 和调用淘宝API的 session 
	    		AuthorInfo authorInfo = AuthorInfo.getInstance();
		        TelephonyManager localTelephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
		        String deviceId  = localTelephonyManager.getDeviceId();
		        String   SubscriberId= localTelephonyManager.getSubscriberId(); 
		        authorInfo.imei= deviceId;
		        authorInfo.imsi= SubscriberId;
	    		ImageView iv=(ImageView)this.findViewById(R.id.logo_bg);
	    		AlphaAnimation aa=new AlphaAnimation(0.1f,1.0f);
	    		aa.setDuration(3000);
	    		iv.startAnimation(aa);
	    		aa.setAnimationListener(new AnimationListener()
	    		{
	    			@Override
	    			public void onAnimationEnd(Animation arg0) {
	    				Intent it=new Intent(AuthorActivity.this,MainActivity.class);
	    				startActivity(it);
	    				finish();
	    			}

	    			public void onAnimationRepeat(Animation animation) {
	    				
	    			}

	    			public void onAnimationStart(Animation animation) {
	    				
	    			}
	    		}
	    		);
	    		
	    }

}
